<?php
	include_once("ConnectionManager.php");
	//Get all Branch
	function getAllBranch(){
		$query = "SELECT * FROM MITI_BRANCH ORDER BY BRA_ORDER,BRA_NAME";
		ConnectionManager::getInstance()->setQuery($query);
		$result = ConnectionManager::getInstance()->query();
		return $result;
	}
	//Get Branch
	function getBranch($bra_id){
		$query = "SELECT * FROM MITI_BRANCH WHERE BRA_ID = $bra_id";
		ConnectionManager::getInstance()->setQuery($query);
		$result = ConnectionManager::getInstance()->query();
		$ret = null;
		if(mysql_num_rows($result) > 0) 
			$ret = mysql_fetch_array($result);
		return $ret;
	}
	//Create Branch
	function createBranch($title, $order, $address){
		$query = "INSERT INTO MITI_BRANCH(BRA_NAME, BRA_ORDER, BRA_ADDRESS) VALUES('$title',$order, '$address')";
		ConnectionManager::getInstance()->setQuery($query);
		$result = ConnectionManager::getInstance()->query();
		return $result;
	}
	//Update Branch
	function updateBranch($bra_id, $bra_name, $bra_order, $bra_address){
		$query = "UPDATE MITI_BRANCH SET BRA_NAME = '$bra_name', BRA_ORDER=$bra_order, BRA_ADDRESS = '$bra_address' WHERE BRA_ID = $bra_id";
		ConnectionManager::getInstance()->setQuery($query);
		$result = ConnectionManager::getInstance()->query();
		return $result;
	}
	//Delete Branch
	function deleteBranch($bra_id){
		$query = "DELETE FROM MITI_BRANCH WHERE BRA_ID = $bra_id";
		ConnectionManager::getInstance()->setQuery($query);
		$result = ConnectionManager::getInstance()->query();
		return $result;
	}
?>